package com.group4.DB;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.group4.DAO.ChannelVideoDAO;

public class ChannelVideo {
	
	private int channelId;
	private int videoId;
	
	static PreparedStatement ps = null;
	static ResultSet rs = null;
	
	
	
	public static boolean addChannelVideo(ChannelVideoDAO channelVideo) {

		boolean result = false;

		if (ConnectionManager.conn == null) {
			System.out.println("Connection is null.");
			return result;
		}

		PreparedStatement ps = null;
		try {
			ps = ConnectionManager.conn
					.prepareStatement(" insert into tbl_channel_video (channel_id, video_id)"
							+ " values (?, ?)");

			ps.setInt(1, channelVideo.getChannelId());
			ps.setInt(2, channelVideo.getVideoId());

			ps.executeUpdate();

			result = true;
		} catch (SQLException e) {
			System.out.println("SQL Error in addChannelVideo. ");
			e.printStackTrace();
		} catch (Exception e) {
			System.out.println("Exception in addChannelVideo. ");
			e.printStackTrace();
		} finally {
			if (ps != null) {
				try {
					ps.close();
				} catch (SQLException e) {
					System.out.println("SQL Error in addChannelVideo. ");
					e.printStackTrace();
				}
			}
		}
		return result;
	}

}
